package com.youyi.yyviewsdklibrary.Dialog.core;

import android.content.Context;
import android.graphics.Rect;
import android.widget.FrameLayout;
import com.youyi.yyviewsdklibrary.Dialog.XPopup;
import com.youyi.yyviewsdklibrary.Dialog.animator.PopupAnimator;
import com.youyi.yyviewsdklibrary.Dialog.animator.TranslateAlphaAnimator;
import com.youyi.yyviewsdklibrary.Dialog.enums.PopupAnimation;
import com.youyi.yyviewsdklibrary.Dialog.enums.PopupPosition;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.OnViewBack;
import com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils;
import com.lkx.liandianqinew.R;

public class VerAttachPopupView extends AttachBottomPopupView {
    protected FrameLayout centerPopupContainer;
    protected OnViewBack mOnViewBack;
    protected int realLayout;

    public VerAttachPopupView(Context context) {
        super(context);
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void onCreate() {
        super.onCreate();
        OnViewBack onViewBack = this.mOnViewBack;
        if (onViewBack != null) {
            onViewBack.result(new XDialog(this, null), getPopupContentView());
        }
    }

    public VerAttachPopupView(Context context, int i, OnViewBack onViewBack) {
        super(context);
        this.realLayout = i;
        this.mOnViewBack = onViewBack;
        this.centerPopupContainer = (FrameLayout) findViewById(R.id.centerPopupContainer);
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public int getImplLayoutId() {
        return this.realLayout;
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView, com.youyi.yyviewsdklibrary.Dialog.core.AttachBottomPopupView
    public void initPopupContent() {
        super.initPopupContent();
        this.defaultOffsetY = 0;
        this.defaultOffsetX = 0;
    }

    @Override // com.youyi.yyviewsdklibrary.Dialog.core.AttachBottomPopupView
    public void doAttach() {
        float f;
        boolean isLayoutRtl = XPopupUtils.isLayoutRtl(getContext());
        getPopupContentView().getMeasuredWidth();
        int measuredHeight = getPopupContentView().getMeasuredHeight();
        boolean z = true;
        if (this.popupInfo.touchPoint != null) {
            if (XPopup.longClickPoint != null) {
                this.popupInfo.touchPoint = XPopup.longClickPoint;
            }
            if (this.popupInfo.touchPoint.x <= ((float) (XPopupUtils.getAppWidth(getContext()) / 2))) {
                z = false;
            }
            this.isShowLeft = z;
            if (!isLayoutRtl) {
                isShowLeftToTarget();
                float f2 = this.popupInfo.touchPoint.x;
                int i = this.defaultOffsetX;
            } else if (this.isShowLeft) {
                XPopupUtils.getAppWidth(getContext());
                float f3 = this.popupInfo.touchPoint.x;
                int i2 = this.defaultOffsetX;
            } else {
                XPopupUtils.getAppWidth(getContext());
                float f4 = this.popupInfo.touchPoint.x;
                getPopupContentView().getMeasuredWidth();
                int i3 = this.defaultOffsetX;
            }
            f = (this.popupInfo.touchPoint.y - (((float) measuredHeight) * 0.5f)) + ((float) this.defaultOffsetY);
        } else {
            Rect atViewRect = this.popupInfo.getAtViewRect();
            if ((atViewRect.left + atViewRect.right) / 2 <= XPopupUtils.getAppWidth(getContext()) / 2) {
                z = false;
            }
            this.isShowLeft = z;
            if (!isLayoutRtl) {
                if (isShowLeftToTarget()) {
                    int i4 = atViewRect.left;
                } else {
                    int i5 = atViewRect.right;
                }
                int i6 = this.defaultOffsetX;
            } else if (this.isShowLeft) {
                XPopupUtils.getAppWidth(getContext());
                int i7 = atViewRect.left;
                int i8 = this.defaultOffsetX;
            } else {
                XPopupUtils.getAppWidth(getContext());
                int i9 = atViewRect.right;
                getPopupContentView().getMeasuredWidth();
                int i10 = this.defaultOffsetX;
            }
            int i11 = atViewRect.top;
            int height = (atViewRect.height() - measuredHeight) / 2;
            int i12 = this.defaultOffsetY;
            f = (float) atViewRect.bottom;
        }
        getActivityContentLeft();
        getPopupContentView().setTranslationX(0.0f);
        getPopupContentView().setTranslationY(f);
        initAndStartAnimation();
    }

    private boolean isShowLeftToTarget() {
        return (this.isShowLeft || this.popupInfo.popupPosition == PopupPosition.Left) && this.popupInfo.popupPosition != PopupPosition.Right;
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView, com.youyi.yyviewsdklibrary.Dialog.core.AttachBottomPopupView
    public PopupAnimator getPopupAnimator() {
        return new TranslateAlphaAnimator(getPopupContentView(), getAnimationDuration(), PopupAnimation.TranslateFromTop);
    }
}
